<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>数值范围</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {
			$.extend($.validator.messages, {
				remote: "参数重复",
				});
			$("#name").focus();
			var validator = $("#inputForm").validate({
				submitHandler: function(form){
					loading('正在提交，请稍等...');
					form.submit();
				},
				errorContainer: "#messageBox",
				errorPlacement: function(error, element) {
					$("#messageBox").text("输入有误，请先更正。");
					if (element.is(":checkbox") || element.is(":radio") || element.parent().is(".input-append")){
						error.appendTo(element.parent().parent());
					} else {
						error.insertAfter(element);
					}
				}
			});
			
			$(".unique").each(function(){
				var name = $(this).attr("name");
				var index = $(this).attr("ind");
				var pre = name.split('.')[0];
				$(this).rules("add",{
					remote: {
					    url: $("#ctx").val()+"/ins/insData/unique",     //后台处理程序
					    type: "get",               //数据发送方式
					    async:false,
					    data: {                     //要传递的数据
					        pre: function() {
					            return pre;
					        },
					        id: function() {
					        	return $("#did"+index).val();
					        },
					        fieldId: function() {
					        	return $("#fid"+index).val();
					        }
					    }
					}
				});
			});
		});
		function submitAll(){
			var url = "${ctx}/ins/insData/save";
            $.ajax({
                type: 'POST',
                url : url,
                async:false,
                data: $('#inputForm').serialize(),             //获取表单数据
                success : function(data) {
                	if(data != "success"){
                	    flag = false;
                        alert(data);
                	}else{
                	    flag = true;
                        alert("保存成功");
                        parent.$.jBox.close(true);
                        parent.$('#btnSubmit').click();
                	}
                        return flag;
                },
                error : function(data){
                	alertx("无权限");
                }
            });
		}
		function submitForm(){                                      //子窗体页面的保存数据方法 通过ajax
			var flag = false;
		    var suc = $("#inputForm").valid();
            if(suc){
				return true;
            }
            return false;
        }
	</script>
</head>
<body>
	<br/>
	<form:form id="inputForm" modelAttribute="insData" action="${ctx}/ins/insData/save" method="post" class="form-horizontal">
		<div class="control-group">
			<label class="control-label">数值范围起：</label>
			<div class="controls">
				<input type='text' value="${numberFrom}" id='numberFrom' name='numberFrom' class='input-mini number'/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">数值范围止：</label>
			<div class="controls">
				<input type='text' value="${numberTo}" id='numberTo' name='numberTo' class='input-mini number'/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">启用数值范围：</label>
			<div class="controls">
				<input id='enableNumberRange' type='checkbox' value='1' <c:if test="${enableNumberRange==1}">checked</c:if>/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">小数位数：</label>
			<div class="controls">
				<select id='digit' class='input-mini' data-value="${digit}">
					<option <c:if test="${digit==1}">selected</c:if> value='1'>1</option>
					<option <c:if test="${digit==2}">selected</c:if> value='2'>2</option>
					<option <c:if test="${digit==3}">selected</c:if> value='3'>3</option>
					<option <c:if test="${digit==4}">selected</c:if> value='4'>4</option>
					<option <c:if test="${digit==5}">selected</c:if> value='5'>5</option>
					<option <c:if test="${digit==6}">selected</c:if> value='6'>6</option>
				</select>
			</div>
		</div>
	</form:form>
</body>
</html>